package  
{
	import flash.events.Event;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundTransform;
	/**
	 * ...
	 * @author Jonathan Semple
	 */
	public class Music
	{
		[Embed(source = "sound/main-loop.mp3")]
		private static var SongLoop:Class;
		
		[Embed(source = "sound/door.mp3")]
		private static var Door:Class;
		
		private var _door:Sound;
		
		private var _song:Sound;
		private var _channel:SoundChannel;
		private var _transform:SoundTransform;
		
		public function Music() 
		{
			_song = new SongLoop();
			_transform = new SoundTransform(0.25);
			
			_door = new Door();
		}
		
		public function start():void {
			_channel = _song.play(0, 999, _transform);
			_channel.addEventListener(Event.SOUND_COMPLETE, loop);
		}
		
		public function loop(event:Event):void {
			_channel = _song.play(0, 999, _transform);
			_channel.addEventListener(Event.SOUND_COMPLETE, loop);
		}
		
		public function door():void {
			_door.play();
		}
	}

}